/*
 * @Description: 表格列配置
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-07-28 21:55:31
 * @LastEditTime: 2025-08-13 09:27:25
 */
import { defineTableCols } from "@/components/TablePage/predefined";
import { tableColsMixin } from "@/helpers/optionsMixin";
import { getUrlFileExt, fileSizeCompute } from "@/ui";

// 文件存储位置
export const filePositions: Record<FileParams["position"], string> = {
  local: "本地磁盘",
  oss: "阿里云oss",
  cos: "腾讯云cos",
  kodo: "七牛云kodo",
};

export default defineTableCols(() => [
  {
    type: "selection",
    align: "center",
    fixed: "left",
    minWidth: 50,
  },
  {
    label: "文件名称",
    minWidth: "120",
    prop: "name",
    fixed: "left",
    showOverflowTooltip: true,
  },
  {
    label: "文件URL",
    minWidth: "300",
    prop: "url",
    showOverflowTooltip: true,
  },
  {
    label: "文件大小",
    minWidth: "100",
    prop: "size",
    formatter(_row, _column, cellValue) {
      return fileSizeCompute(cellValue);
    },
  },
  {
    label: "存储位置",
    minWidth: "100",
    prop: "position",
    formatter(_row, _column, cellValue) {
      return filePositions[cellValue as FileParams["position"]];
    },
  },
  {
    label: "文件类目",
    minWidth: "100",
    prop: "group",
    showOverflowTooltip: true,
  },
  {
    label: "扩展名",
    minWidth: "100",
    prop: "url",
    formatter(_row, _column, cellValue) {
      return getUrlFileExt(cellValue);
    },
  },
  ...tableColsMixin,
  {
    label: "操作",
    minWidth: "210",
    useRowBtns: true,
    fixed: "right",
  },
]);
